package com.demo;

import jakarta.annotation.PostConstruct;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageProducer {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void sendMessage(String topic, String message) {
        rocketMQTemplate.convertAndSend(topic, message);
    }
    @PostConstruct
     public void init() {
//        for (int i = 0; i < 100; i++) {
            sendMessage("my-topic", "Hello, RocketMQ!" );
//        }

    }
}